package com.lantian.uavmaterial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.lantian.uavmaterial.domain.UavTechnicalSpecifications;
import com.lantian.uavmaterial.service.IUavTechnicalSpecificationsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lantian.common.annotation.Log;
import com.lantian.common.core.controller.BaseController;
import com.lantian.common.core.domain.AjaxResult;
import com.lantian.common.enums.BusinessType;

import com.lantian.common.utils.poi.ExcelUtil;
import com.lantian.common.core.page.TableDataInfo;

/**
 * 无人机基础信息
 * 
 * @author lantian
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/uav/specifications")
public class UavTechnicalSpecificationsController extends BaseController
{
    @Autowired
    private IUavTechnicalSpecificationsService uavTechnicalSpecificationsService;

    /**
     * 查询无人机基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('uav:specifications:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavTechnicalSpecifications uavTechnicalSpecifications)
    {
        startPage();
        List<UavTechnicalSpecifications> list = uavTechnicalSpecificationsService.selectUavTechnicalSpecificationsList(uavTechnicalSpecifications);
        return getDataTable(list);
    }

    /**
     * 导出无人机基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('uav:specifications:export')")
    @Log(title = "无人机基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavTechnicalSpecifications uavTechnicalSpecifications)
    {
        List<UavTechnicalSpecifications> list = uavTechnicalSpecificationsService.selectUavTechnicalSpecificationsList(uavTechnicalSpecifications);
        ExcelUtil<UavTechnicalSpecifications> util = new ExcelUtil<UavTechnicalSpecifications>(UavTechnicalSpecifications.class);
        util.exportExcel(response, list, "无人机基础信息数据");
    }

    /**
     * 获取无人机基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('uav:specifications:query')")
    @GetMapping(value = "/{uavId}")
    public AjaxResult getInfo(@PathVariable("uavId") String uavId)
    {
        return success(uavTechnicalSpecificationsService.selectUavTechnicalSpecificationsByUavId(uavId));
    }

    /**
     * 新增无人机基础信息
     */
    @PreAuthorize("@ss.hasPermi('uav:specifications:add')")
    @Log(title = "无人机基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavTechnicalSpecifications uavTechnicalSpecifications)
    {
        return toAjax(uavTechnicalSpecificationsService.insertUavTechnicalSpecifications(uavTechnicalSpecifications));
    }

    /**
     * 修改无人机基础信息
     */
    @PreAuthorize("@ss.hasPermi('uav:specifications:edit')")
    @Log(title = "无人机基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavTechnicalSpecifications uavTechnicalSpecifications)
    {
        return toAjax(uavTechnicalSpecificationsService.updateUavTechnicalSpecifications(uavTechnicalSpecifications));
    }

    /**
     * 删除无人机基础信息
     */
    @PreAuthorize("@ss.hasPermi('uav:specifications:remove')")
    @Log(title = "无人机基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uavIds}")
    public AjaxResult remove(@PathVariable String[] uavIds)
    {
        return toAjax(uavTechnicalSpecificationsService.deleteUavTechnicalSpecificationsByUavIds(uavIds));
    }
}
